package studentsystem;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;

public class SQL {

    // 数据库的用户名与密码，需要根据自己的设置
    Connection conn;

    public Connection getConn() {
        try {
            Class.forName("com.mysql.cj.jdbc.Driver");

            String url = "jdbc:mysql://localhost:3306/test?useSSL=false&allowPublicKeyRetrieval=true&serverTimezone=UTC";    //JDBC的URL

            conn = DriverManager.getConnection(url, "root", "123456"); //建立数据库连接，获得连接对象conn
        } catch (ClassNotFoundException e) {
            e.printStackTrace();
        } catch (SQLException e) {
            e.printStackTrace();
        }
        return conn;
    }

    public static void main(String[] args) {
        System.out.println("hello world!");
    }
}